﻿using System.Linq;
using System;

namespace CometDocs
{
    /// <summary>
    /// Represents a CometDocs file.
    /// Its original descriptions is available here: https://www.cometdocs.com/developer/apiDocumentation#types
    /// </summary>
    public class File : FileInfo
    {
        private byte[] content;

        /// <summary>
        /// The file content, useful for uploading from and downloading to local file-system.
        /// </summary>
        public byte[] Content
        {
            get
            {
                return content;
            }
            set
            {
                if (value == null) throw new ArgumentNullException("value", "Content cannot be null; for empty files provide an empty array or do not provide anything!");

                this.content = value;
            }
        }

        /// <summary>
        /// Create a new FileInfo instance.
        /// If the provided name is "Test.pdf" the resulting File instance "Name" will be "Test" and the "Extension" "pdf".
        /// </summary>
        /// <param name="nameWithExtension">The full file name: e.g. "Test.pdf".</param>
        public File(string nameWithExtension = null)
            : base(nameWithExtension)
        {
            content = new byte[0];
        }
    }
}
